﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using YBApproval.Model;

namespace YBApproval.UserControls
{
    public partial class UCApprovalView : System.Web.UI.UserControl
    {
        private InstanceApproval _approval = null;
        public InstanceApproval ApprovalIns 
        { 
            get { return _approval; } 
            set 
            { 
                _approval = value;

                if (_approval != null)
                {
                    this.txt_Comments.Text = _approval.Comment;
                    this.lbl_ApproveDate.Text = _approval.ApproveDate.Value.ToShortDateString();
                    this.lbl_Approver.Text = _approval.ApproverName;
                    if (_approval.IsApproved)
                    {
                        this.lbl_Status.Text = "同意";
                    }
                    if (_approval.IsDenied)
                    {
                        this.lbl_Status.Text = "不同意";
                    }
                    if (!_approval.IsApproved && !_approval.IsDenied)
                    {
                        this.lbl_Status.Text = "未审批";
                    }
                }
            } 
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (_approval != null)
            {
                this.txt_Comments.Text = _approval.Comment;
                this.lbl_ApproveDate.Text = _approval.ApproveDate.Value.ToShortDateString();
                this.lbl_Approver.Text = _approval.ApproverName;
                if (_approval.IsApproved)
                {
                    this.lbl_Status.Text = "同意";
                }
                if (_approval.IsDenied)
                {
                    this.lbl_Status.Text = "不同意";
                }
            }
        }
    }
}